import { useI18n } from '/@/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '/@/components/Table';
// import { basInvListData } from '/@/api/bas/inv/basInv';
import { basInvOuterListData } from '/@/api/bas/invouter/basInvOuter';
import { h } from 'vue';
import { useGlobSetting } from '/@/hooks/setting';
const { urlPrefix } = useGlobSetting();

const { t } = useI18n('sys.empUser');

const modalProps = {
  title: t('外部商品选择'),
};

const searchForm: FormProps = {
  baseColProps: { lg: 6, md: 8 },
  labelWidth: 80,
  schemas: [
    {
      label: t('存货名称'),
      field: 'invName',
      component: 'Input',
    },
  ],
};

const tableColumns: BasicColumn[] = [
  {
    title: t('封面图'),
    dataIndex: 'picUrl',
    key: 'a.pic_url',
    // sorter: true,
    align: 'left',
    width: 140,
    slot: 'picUrl',
    customRender: ({ text }) => {
      return h('img', {
        src: urlPrefix + text,
        alt: '封面图',
        style: {
          width: '40px',
          height: '40px',
        },
      });
    },
  },
  {
    title: t('存货名称'),
    dataIndex: 'invName',
    key: 'a.invName',
    sorter: true,
    align: 'left',
    width: 240,
  },
  // 规格型号
  {
    title: t('规格型号'),
    dataIndex: 'invStd',
    key: 'a.inv_std',
    sorter: true,
    align: 'left',
    width: 100,
  },
  // 封面图

  {
    title: t('是否发布'),
    dataIndex: 'fbStatus',
    key: 'a.fb_status',
    sorter: true,
    width: 100,
    dictType: 'shop_fb_status',
  },
];

const tableProps: BasicTableProps = {
  api: basInvOuterListData,
  beforeFetch: (params) => {
    params['isAll'] = true;
    //params['ope'] = '1';
    return params;
  },
  columns: tableColumns,
  formConfig: searchForm,
  rowKey: 'invName',
};

export default {
  modalProps,
  tableProps,
  itemCode: 'invCode',
  itemName: 'invName',
};
